<?php

namespace Doc\Controller;

use Common\Controller\BaseController;
use Common\Model\AdModel;
use Common\Model\ClassModel;
use Common\Model\IndexModel;

class IndexController extends BaseController {

    /**
     * 文档-首页：展示文档列表
     */
    public function index(){
        $c = (int)I('get.cid', 0);      //分类id
        $p = I('get.pid', 1);           //页数
        $pcount = 12;                   //每页显示数量
        $result = IndexModel::getDocList($c, $p, $pcount);
        $class = $c > 0 ? ClassModel::getClassById($c) : array();
        $this->assign('cate', ClassModel::getIndexDocClass());
        $this->assign('list', $result['list']);
        $this->assign('page', page($result['count'], $pcount, $p));
        $this->assign('mark', $c);
        $this->assign('ad', AdModel::getIndexAd());
        $this->assign('title', ($class ? $class['name'].' - ' : '').'Docs'.($p == 1 ? '' : '[第'.$p.'页]'));
        $this->assign('description', $class ? '我网'.$class['name'].'分类下的第'.$p.'页文档，'.$class['desc'] : '我网所有分类下的第'.$p.'页文档，这些文档以收藏数倒序排序，为你展示最丰富精彩的知识！');
        $this->display();
    }

}